async function loadData() {
    let tbody = document.querySelector('#data');
    const parent = tbody.parentElement;
    tbody.remove();
    tbody = document.createElement('tbody');
    tbody.id = 'data';
    parent.appendChild(tbody)
    const res = await fetch('/api/data');
    const json = await res.json();
    const template = `<td>{manufacture}</td><td>{all}</td><td>{q1}</td><td>{q2}</td><td>{q3}</td><td>{q3-comp}</td>`;
    for (const item of json.data) {
        const inner = template
            .replace(/\{manufacture\}/g, item['Manufacture'])
            .replace(/\{q1\}/g, item['Selldata'][0].toFixed(2).toString())
            .replace(/\{q2\}/g, item['Selldata'][1].toFixed(2).toString())
            .replace(/\{q3\}/g, item['Selldata'][2].toFixed(2).toString())
            .replace(/\{q3-comp\}/g, (parseFloat(item['Q3comp']) * 100).toFixed(2).toString() + '%')
            .replace(/\{all\}/g, (item['Selldata'][0] + item['Selldata'][1] + item['Selldata'][2]).toFixed(2).toString())
        const elem = document.createElement('tr');
        elem.innerHTML = inner;
        tbody.appendChild(elem);
    }
}
